<html>
	<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta charset="utf-8" />
		<script src='bsp/TcpClient.js'></script>
	</head>
	<body>
		<div id='output'></div>
		<script>
			var sck = new TcpClient('localhost', 8253, TcpClient.DATA_TYPE_PACKET, 2000);
			
			sck.on_connect = function () {
				var bs = new Object();
				bs.a = "Hello";
				bs.b = "World";
				bs.c = 123456;
				bs.d = 1.23456;
				bs.e = -123;
				bs.f = new Array();
				bs.f[0] = 100;
				bs.f[1] = 200;
				bs.f[2] = new Object();
				bs.f[2].aa = '汉字';
				sck.send(2000, bs);
                console.log("WebSocket connected");
			}
			
			sck.on_data = function () {
                console.log("WebSocket packet data");
                console.log(sck.get_packet());
                
                return;
			}
			
			sck.on_heartbeat = function () {
				console.log('Heartbeat response');
			}
            
            sck.on_close = function() {
                console.log("WebSocket closed");
            }
			
			sck.connect();
		</script>
	</body>
</html>
